#-*- coding: utf-8 -*-
import json
import time
from entity import Entity
from apihandler import json_encode

class User (Entity):
    _default_data = {
        'id'       : 0,
        'name'     : '',
        'password' : '',
        'sid'      : '',
        'regDate'  : '',
        'level'    : 0,
    }

    def serialize(self):
        """
        Сериализует данные в JSON для отправки пользователю.
        """
        data = self._data.copy()
        try:
            data['regDate'] = str(int(time.mktime(data['regDate'].timetuple())))
        except: pass
        del data['password']
        return data

    @staticmethod
    def unserialize(self, json):
        return User()
